package day17;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

//键找值遍历
public class Map01 {
    public static void main(String[] args) {
        Map map = new HashMap();
        map.put("KFC", "香辣鸡腿堡");
        map.put("麦当劳","麦辣鸡腿堡");
        map.put("塔斯汀","中国汉堡");

        //增强for遍历
        Set<String> keys = map.keySet();
        for (String key : keys) {
            Object value = map.get(key);
            System.out.println(key + ":" + value);
        }

        //迭代器遍历
        Iterator<String> it = keys.iterator();
        while (it.hasNext()) {
            String key = it.next();
            Object value = map.get(key);
            System.out.println(key + ":" + value);
        }

        //Lambda方法
        keys.forEach(key -> System.out.println(key + ":" + map.get(key)));
    }
}
